package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.JiajiaCharityActivities;
import com.ruoyi.system.mapper.JiajiaCharityActivitiesMapper;
import com.ruoyi.system.service.IJiajiaCharityActivitiesService;
import com.ruoyi.system.utils.TokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 公益活动信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@Service
public class JiajiaCharityActivitiesServiceImpl implements IJiajiaCharityActivitiesService
{
    @Autowired
    private JiajiaCharityActivitiesMapper jiajiaCharityActivitiesMapper;

    /**
     * 查询公益活动信息
     * 
     * @param id 公益活动信息主键
     * @return 公益活动信息
     */
    @Override
    public JiajiaCharityActivities selectJiajiaCharityActivitiesById(Long id)
    {
        return jiajiaCharityActivitiesMapper.selectJiajiaCharityActivitiesById(id);
    }

    /**
     * 查询公益活动信息列表
     * 
     * @param jiajiaCharityActivities 公益活动信息
     * @return 公益活动信息
     */
    @Override
    public List<JiajiaCharityActivities> selectJiajiaCharityActivitiesList(JiajiaCharityActivities jiajiaCharityActivities) {
        List<JiajiaCharityActivities> charityActivities = jiajiaCharityActivitiesMapper.selectJiajiaCharityActivitiesList(jiajiaCharityActivities);
        return charityActivities;
    }

    /**
     * 新增公益活动信息
     * 
     * @param jiajiaCharityActivities 公益活动信息
     * @return 结果
     */
    @Override
    public int insertJiajiaCharityActivities(JiajiaCharityActivities jiajiaCharityActivities)
    {
        jiajiaCharityActivities.setCreateTime(DateUtils.getNowDate());
        return jiajiaCharityActivitiesMapper.insertJiajiaCharityActivities(jiajiaCharityActivities);
    }

    /**
     * 修改公益活动信息
     * 
     * @param jiajiaCharityActivities 公益活动信息
     * @return 结果
     */
    @Override
    public int updateJiajiaCharityActivities(JiajiaCharityActivities jiajiaCharityActivities)
    {
        jiajiaCharityActivities.setUpdateTime(DateUtils.getNowDate());
        return jiajiaCharityActivitiesMapper.updateJiajiaCharityActivities(jiajiaCharityActivities);
    }

    /**
     * 批量删除公益活动信息
     * 
     * @param ids 需要删除的公益活动信息主键
     * @return 结果
     */
    @Override
    public int deleteJiajiaCharityActivitiesByIds(String ids)
    {
        return jiajiaCharityActivitiesMapper.deleteJiajiaCharityActivitiesByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除公益活动信息信息
     * 
     * @param id 公益活动信息主键
     * @return 结果
     */
    @Override
    public int deleteJiajiaCharityActivitiesById(Long id)
    {
        return jiajiaCharityActivitiesMapper.deleteJiajiaCharityActivitiesById(id);
    }

    @Override
    public List<JiajiaCharityActivities> selectApiJiajiaCharityActivitiesList(JiajiaCharityActivities jiajiaCharityActivities) {
        jiajiaCharityActivities.setUserId(TokenUtil.getUid());
        List<JiajiaCharityActivities> list =jiajiaCharityActivitiesMapper.selectApiJiajiaCharityActivitiesList(jiajiaCharityActivities);
        return list;
    }

    @Override
    public JiajiaCharityActivities selectApiJiajiaCharityActivitiesById(Long id) {
        return jiajiaCharityActivitiesMapper.selectApiJiajiaCharityActivitiesById(id, TokenUtil.getUid());
    }
}
